package GameLogic
{
	import DataStore.BmpDataPool;
	import flash.display.Bitmap;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.ui.Mouse;
	import flash.ui.MouseCursor;
	import flash.utils.Dictionary;
	
	public class ImgBtn extends Sprite
	{
		public var clickEvent:Function;
		private var bmp:Bitmap;
		private var note:String;
		public function ImgBtn(_index:int,_note:String)
		{
			var t:Dictionary = BmpDataPool.LuaeditPool;
			bmp =  new Bitmap(BmpDataPool.LuaeditPool[_index]);
			note = _note;
			addChild(bmp);
			this.addEventListener(MouseEvent.MOUSE_OVER, function(e:MouseEvent):void
			{
				Mouse.cursor = MouseCursor.BUTTON;
				AddTooltip();
			});
			
			this.addEventListener(MouseEvent.MOUSE_OUT, function(e:Event):void
			{
				Mouse.cursor = MouseCursor.AUTO;
				Game.RemoveTooltip();
			});
			this.addEventListener(MouseEvent.CLICK, function(e:Event):void
			{
				clickEvent();
			});
		}
		public function Addclick(_handler:Function):void
		{
			clickEvent = _handler;
		}
		
		private function AddTooltip():void
		{
			Game.AddTooltip(this, bmp, note, -note.length, 30);
		}
	}
}